#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>


#define LOG "log.txt"
int main()
{
  fprintf(stdout,"hello stdout!!!\n");
  fprintf(stdout,"hello stdout!!!\n");
  fprintf(stdout,"hello stdout!!!\n");

  fprintf(stderr,"hello stderr!!!\n");
  fprintf(stderr,"hello stderr!!!\n");
  fprintf(stderr,"hello stderr!!!\n");


  //umask(0);
  ////int fd = open(LOG,O_WRONLY | O_CREAT | O_TRUNC,0666);
  //int fd = open(LOG,O_RDONLY);
  //if(fd == -1)
  //{
  //  printf("fd:%d  errno:%d,errstring:%s",fd,errno,strerror(errno));
  //}
  //printf("%d\n",fd);

  //char buffer[1024];
  //int ssize = read(fd,buffer,sizeof(buffer)-1);
  //if(ssize > 0)
  //{
  //  buffer[ssize] = '\0';
  //  printf("%s",buffer);
  //}

  //const char* msg = "hello nhy";
  //int cnt = 5;

  //while(cnt)
  //{
  //  char line[128];
  //  snprintf(line,sizeof(line),"%s,%d\n",msg,cnt);

  //  write(fd,line,strlen(line));
  //  cnt--;
  //}

  //printf("hello printf--stdout\n");
  //fprintf(stdout,"hello fprintf->stdout\n");
  //fprintf(stderr,"hello fprintf->stderr\n");
  // w默认写方式打开文件，如果文件不存在，就创建文件
  // a不会清空，每次写入都从文件末尾写入
  //
  //FILE* fp =fopen(LOG,"w");
  //if(fp == NULL)
  //{
  //  perror("fopen");
  //  return 1;
  //}

  
  

  return 0;
}
